package com.company.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.company.project.common.utils.DataResult;

import com.company.project.entity.EJkzRecordLogEntity;
import com.company.project.service.EJkzRecordLogService;

import javax.annotation.Resource;


/**
 * 健康证上传记录
 *
 * @author liuhui

 * @date 2020-11-15 17:06:22
 */
@Api(tags = "体检上传记录")
@RestController
@RequestMapping("/jkz/log")
public class EJkzRecordLogController {
    @Resource
    private EJkzRecordLogService eJkzRecordLogService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/eJkzRecordLog")
    public String eJkzRecordLog() {
        return "ejkzrecordlog/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("eJkzRecordLog/add")
    @RequiresPermissions("eJkzRecordLog:add")
    @ResponseBody
    public DataResult add(@RequestBody EJkzRecordLogEntity eJkzRecordLog){
        eJkzRecordLogService.save(eJkzRecordLog);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("eJkzRecordLog/delete")
    @RequiresPermissions("eJkzRecordLog:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        eJkzRecordLogService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("eJkzRecordLog/update")
    @RequiresPermissions("eJkzRecordLog:update")
    @ResponseBody
    public DataResult update(@RequestBody EJkzRecordLogEntity eJkzRecordLog){
        eJkzRecordLogService.updateById(eJkzRecordLog);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("eJkzRecordLog/listByPage")
    @RequiresPermissions("eJkzRecordLog:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody EJkzRecordLogEntity eJkzRecordLog){
        Page page = new Page(eJkzRecordLog.getPage(), eJkzRecordLog.getLimit());
        LambdaQueryWrapper<EJkzRecordLogEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(EJkzRecordLogEntity::getId, eJkzRecordLog.getId());
        IPage<EJkzRecordLogEntity> iPage = eJkzRecordLogService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
